Skip to content

ADFA-4394: Report attached input devices and external displays to analytics and GlitchTip - #1663

Merged
Daniel-ADFA merged 3 commits into
stagefrom
ADFA-4394
Aug 13, 2026
Merged

ADFA-4394: Report attached input devices and external displays to analytics and GlitchTip#1663
Daniel-ADFA merged 3 commits into
stagefrom
ADFA-4394

Conversation

@Daniel-ADFA

Copy link
Copy Markdown
Contributor

No description provided.

@Daniel-ADFA
Daniel-ADFA requested a review from a team August 12, 2026 09:07

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e7d62910-ae2c-4514-b243-4a03cc10addc

📥 Commits

Reviewing files that changed from the base of the PR and between 44ddf2e and 2e9e291.

📒 Files selected for processing (3)
  • app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.kt
  • app/src/main/java/com/itsaky/androidide/app/DeviceProtectedApplicationLoader.kt
  • app/src/test/java/com/itsaky/androidide/handlers/GlitchTipDiagnosticsContextTest.kt
🚧 Files skipped from review as they are similar to previous changes (3)
  • app/src/main/java/com/itsaky/androidide/app/DeviceProtectedApplicationLoader.kt
  • app/src/test/java/com/itsaky/androidide/handlers/GlitchTipDiagnosticsContextTest.kt
  • app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.kt

📝 Walkthrough
  • Add analytics for attached mice, external keyboards, touchpads, styluses, gamepads, and external displays.
  • Report attached-device counts through the attached_devices analytics event.
  • Add attached-device counts to GlitchTip diagnostic context.
  • Exclude virtual, internal, and ambiguous touchscreen devices from classification.
  • Add API-specific handling for external-device detection.
  • Add unit and Robolectric tests for classification, metric serialization, and GlitchTip failure handling.
  • Risk: Device classification depends on Android input-device metadata and API-specific behavior.
  • Risk: Collection failures produce empty analytics counts and can omit the GlitchTip attached-device context.

Walkthrough

The change collects counts for supported attached devices and external displays. It reports the snapshot through analytics and GlitchTip diagnostics. It adds Android-version handling, failure isolation, and focused tests.

Changes

Attached device analytics

Layer / File(s) Summary
Device classification and collection
app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.kt, app/src/test/java/com/itsaky/androidide/analytics/AttachedDevicesCollectorTest.kt
Adds device classes, snapshot data, filtering, aggregation, external-display counting, API 28 fallback handling, and classification tests.
Analytics metric integration
app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesMetric.kt, app/src/main/java/com/itsaky/androidide/app/DeviceProtectedApplicationLoader.kt, app/src/test/java/com/itsaky/androidide/analytics/AttachedDevicesMetricTest.kt
Serializes six counts into the attached_devices metric and reports it during analytics initialization.
Diagnostics context integration
app/src/main/java/com/itsaky/androidide/handlers/GlitchTipDiagnosticsContext.kt, app/src/test/java/com/itsaky/androidide/handlers/GlitchTipDiagnosticsContextTest.kt
Adds attached-device counts to diagnostic events and verifies isolated handling of collection failures.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DeviceProtectedApplicationLoader
  participant AttachedDevicesCollector
  participant AttachedDevicesMetric
  DeviceProtectedApplicationLoader->>AttachedDevicesCollector: collect(application context)
  AttachedDevicesCollector-->>DeviceProtectedApplicationLoader: AttachedDevicesSnapshot
  DeviceProtectedApplicationLoader->>AttachedDevicesMetric: report snapshot counts
  AttachedDevicesMetric-->>DeviceProtectedApplicationLoader: attached_devices event
Loading

Possibly related PRs

Poem

I’m a rabbit counting mice in a row,
Keyboards and styluses join the show.
Touchpads, gamepads, displays align,
Six small counts fit in a design.
If collection fails, the rest stays bright.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided, so its relevance to the changeset cannot be assessed. Add a brief description that summarizes attached-device collection and reporting to analytics and GlitchTip.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes reporting attached input devices and external displays to analytics and GlitchTip.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ADFA-4394

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.kt (1)

9-26: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document the public attached-device contract.

The new public types and functions expose classification and telemetry semantics without KDoc.

  • app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.kt#L9-L26: Document each device class and each snapshot count.
  • app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.kt#L37-L63: Document classification rules, API-level fallback behavior, and the meaning of isExternal = null.
  • app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesMetric.kt#L5-L18: Document the event contract and Bundle parameter units.

As per coding guidelines, "Public classes, functions, and non-obvious logic must have KDoc or Javadoc documenting contracts, rationale, threading, nullability, side effects, or units."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.kt`
around lines 9 - 26, Document the public attached-device contract with KDoc: in
app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.kt
lines 9-26, describe each AttachedDeviceClass value and each
AttachedDevicesSnapshot count; in lines 37-63, document classification rules,
API-level fallback behavior, and the meaning of isExternal = null; in
app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesMetric.kt lines
5-18, document the event contract and Bundle parameter units.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.kt`:
- Around line 64-67: Update the classCounts and externalDisplays collection in
AttachedDevicesCollector to replace runCatching with narrow catches for the
expected recoverable platform exception types only. Log each handled failure
through the existing SLF4J logger before returning the respective emptyMap() or
0 fallback, and allow fatal or unexpected throwables to propagate.

In
`@app/src/main/java/com/itsaky/androidide/app/DeviceProtectedApplicationLoader.kt`:
- Around line 189-195: Update initializeAnalytics in the startup path so
AttachedDevicesMetric collection and tracking occur only after application
startup completes, not during load(). Schedule the work asynchronously without
blocking the main thread, and isolate analytics scheduling, collection, and
reporting failures so they cannot affect startup.

In
`@app/src/test/java/com/itsaky/androidide/handlers/GlitchTipDiagnosticsContextTest.kt`:
- Around line 101-105: Update the test method `attached devices context is
included on every event` to mock `AttachedDevicesCollector.collect(app)` with
six distinct counts, then assert that `event.contexts["attached_devices"]`
contains exactly the six expected keys and their corresponding values.

---

Nitpick comments:
In
`@app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.kt`:
- Around line 9-26: Document the public attached-device contract with KDoc: in
app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.kt
lines 9-26, describe each AttachedDeviceClass value and each
AttachedDevicesSnapshot count; in lines 37-63, document classification rules,
API-level fallback behavior, and the meaning of isExternal = null; in
app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesMetric.kt lines
5-18, document the event contract and Bundle parameter units.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 952d6255-2d86-4140-9d68-f158e7eccf0c

📥 Commits

Reviewing files that changed from the base of the PR and between ffb63dd and 44ddf2e.

📒 Files selected for processing (7)
  • app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.kt
  • app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesMetric.kt
  • app/src/main/java/com/itsaky/androidide/app/DeviceProtectedApplicationLoader.kt
  • app/src/main/java/com/itsaky/androidide/handlers/GlitchTipDiagnosticsContext.kt
  • app/src/test/java/com/itsaky/androidide/analytics/AttachedDevicesCollectorTest.kt
  • app/src/test/java/com/itsaky/androidide/analytics/AttachedDevicesMetricTest.kt
  • app/src/test/java/com/itsaky/androidide/handlers/GlitchTipDiagnosticsContextTest.kt

Comment thread app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.kt Outdated
Comment thread app/src/main/java/com/itsaky/androidide/app/DeviceProtectedApplicationLoader.kt Outdated
Narrow the collector guards to RuntimeException and log fallbacks,
move metric collection and tracking off the main dispatcher, and
assert the exact attached_devices context map in the test.
@Daniel-ADFA
Daniel-ADFA merged commit bf46d5e into stage Aug 13, 2026
4 checks passed
@Daniel-ADFA
Daniel-ADFA deleted the ADFA-4394 branch August 13, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants